<?php
/**
 * @package Component Metromap for Joomla! 1.5
 * @version $Id: install.metromap.php 4 2010-08-17 13:58:48Z batyrkin $
 * @author Batyrkin Anton
 * @copyright (C) 2010- Batyrkin Anton
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 **/

defined( '_JEXEC' ) or die();
jimport( 'joomla.filesystem.folder' );

function com_install() {

	$db =& JFactory::getDBO();
	$db->setQuery('SELECT * FROM `#__categories` WHERE section = "com_metromap"');
	$sitys = $db->loadAssocList();

	if (count($sitys) > 0) {

	}else{
		$db->setQuery('INSERT INTO `#__categories` SET title="Москва", alias="Moscow", section = "com_metromap", image_position="left", published=1, ordering=1');
		if (!$result = $db->query()){$msgError = $db->stderr() . '<br />';}
	}

	if ($msgError !='') {
		$msg = JText::_( 'Metromap' ) .' '. JText::_( 'not' ) .' '. JText::_( 'successfully installed' ). ': ' . $msgError;
	} else {
		$link = 'index.php?option=com_metromap';
		$msg = JText::_( 'Metromap' ) .' '. JText::_( 'successfully installed' ).'<br />';
		$msg .= '<a href="'.$link.'">'.JText::_( 'Go to component administration' ).'</a>';
	}

	echo $msg;

}
